package com.fate.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fate.system.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 47349
 * @description 针对表【sys_user(用户表)】的数据库操作Mapper
 * @createDate 2024-08-09 02:11:25 @Entity com.fate.system.entity.User
 */
public interface UserMapper extends BaseMapper<User> {
  /**
   * 查询该roleId是否被用户表占用（占用的数量）
   *
   * @param roleId 角色id
   * @return 数量
   */
  @Select("SELECT COUNT(*) FROM sys_user WHERE #{roleId} = ANY(role_ids)")
  int isRoleIdReferenced(@Param("roleId") String roleId);
}
